package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Xunchaxitong;
import com.ruoyi.system.service.IXunchaxitongService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡查系统表Controller
 * 
 * @author Quilan
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/xunchaxitong")
public class XunchaxitongController extends BaseController
{
    @Autowired
    private IXunchaxitongService xunchaxitongService;

    /**
     * 查询巡查系统表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:list')")
    @GetMapping("/list")
    public TableDataInfo list(Xunchaxitong xunchaxitong)
    {
        startPage();
        List<Xunchaxitong> list = xunchaxitongService.selectXunchaxitongList(xunchaxitong);
        return getDataTable(list);
    }

    /**
     * 导出巡查系统表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:export')")
    @Log(title = "巡查系统表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xunchaxitong xunchaxitong)
    {
        List<Xunchaxitong> list = xunchaxitongService.selectXunchaxitongList(xunchaxitong);
        ExcelUtil<Xunchaxitong> util = new ExcelUtil<Xunchaxitong>(Xunchaxitong.class);
        util.exportExcel(response, list, "巡查系统表数据");
    }

    /**
     * 获取巡查系统表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xunchaxitongService.selectXunchaxitongById(id));
    }

    /**
     * 新增巡查系统表
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:add')")
    @Log(title = "巡查系统表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xunchaxitong xunchaxitong)
    {
        return toAjax(xunchaxitongService.insertXunchaxitong(xunchaxitong));
    }

    /**
     * 修改巡查系统表
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:edit')")
    @Log(title = "巡查系统表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xunchaxitong xunchaxitong)
    {
        return toAjax(xunchaxitongService.updateXunchaxitong(xunchaxitong));
    }

    /**
     * 删除巡查系统表
     */
    @PreAuthorize("@ss.hasPermi('system:xunchaxitong:remove')")
    @Log(title = "巡查系统表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xunchaxitongService.deleteXunchaxitongByIds(ids));
    }
}
